package cn.lanqiao.service.impl;

import java.io.File;
import java.io.IOException;

import javax.swing.JTable;

import cn.lanqiao.entity.Student;
import cn.lanqiao.entity.Users;
import cn.lanqiao.service.UserService;

public class UserServiceImpl implements UserService {
	private cn.lanqiao.dao.UserDao dao = new cn.lanqiao.dao.impl.UserDaoImpl();

	@Override
	public String datasBackup() {
		// TODO 自动生成的方法存根
		return null;
	}

	@Override
	public String datasRecovery() {
		// TODO 自动生成的方法存根
		return null;
	}

	@Override
	public Object[][] lists() {
		return dao.getAllstudents();
	}

	@Override
	public void deleteStu(String id) {
		dao.deleteStu(id);
	}

	@Override
	public void updateUsers(String sid, Student student) {
		dao.updateStudent(sid, student);

	}

	@Override
	public void addStudent(Student student) {
		dao.addStudent(student);
	}

	@Override
	public void exportTable(JTable table, File file) throws IOException {
		dao.exportTable(table, file);
	}

	// 登录判断
	@Override
	public Users login(String account, String password) {
		Users currentAccount = dao.getUserByLoginId(account);
		Users user = null;
		if (currentAccount != null) {
			if (currentAccount.getPassword().equals(password)) {
				user = currentAccount;
			}
		}
		return user;
	}

	// 手机判断
	@Override
	public Users send(String telephone) {
		Users currentAccount = dao.getUserByTelephone(telephone);
		Users user = null;
		if (currentAccount != null) {
			user = currentAccount;
		}
		return user;
	}

	// 验证码
	@Override
	public String Verification() {
		String verifyCode = dao.sendVerification();
		return verifyCode;
	}

	// 修改密码
	@Override
	public int newPassword(String telephone, String newPassword) {
		int intresult = dao.updatePassword(telephone, newPassword);
		return intresult;
	}

	@Override
	public Object[][] getAllScores() {
		return dao.getAllScores();
	}

	@Override
	public Student getStudentinformation(String sid) {
		return dao.getStudentinformation(sid);
	}

	@Override
	public Object[][] getAllUsers() {
		return dao.getAllUsers();
	}

	@Override
	public void deleteUser(String sid) {
		dao.deleteUser(sid);
	}

	@Override
	public void addUser(Users users) {
		dao.addUser(users);
	}

	@Override
	public void updateUser(String account, Users user) {
		dao.updateUser(account, user);
	}
}
